package ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.evento;

import model.Aplicacion.Agenda;

import org.apache.wicket.extensions.markup.html.form.DateTextField;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.CompoundPropertyModel;

import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.HomePage;
import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.apliccion.ContactoDatProvider;
import ar.edu.unq.tpi.labso.rochi.agendaRochi.Wicket.apliccion.EventoDatProvider;
import clasesPrincipales.Contacto;
import clasesPrincipales.Evento;

public class AgregarEventoPage extends WebPage{

	private static final long serialVersionUID = 1L;
	

	public AgregarEventoPage(){
		
		
		super(new CompoundPropertyModel<Evento>(
				Agenda.getHome(Evento.class).createExample()));
		Form<Evento> form = new Form<Evento>("eventoAgregarForm");
		
		this.add(form);
		form.add(new Label("lbl_finicio","Fecha inicial"));
	    form.add(new DateTextField ("fechaInicio"));
	    form.add(new Label("lbl_ffin","Fecha final"));
	    form.add(new DateTextField ("fechaFin"));
	    form.add(new Label("lbl_descr","Descripcion"));
	    form.add(new TextField<String>("descripcion"));
	    form.add(new Label("lbl_importante","Es importante"));
	    form.add(new CheckBox("esImportante"));
		
	    

        final EventoDatProvider provider =new EventoDatProvider();

		form.add(new SubmitLink("botonAgregarEvento"){
		private static final long serialVersionUID = 1L;
		public void onSubmit() {
			provider.agregar((Evento)AgregarEventoPage.this.getDefaultModelObject());
			this.setResponsePage(new HomePage());
			}});
		
		form.add(new Link("botonVolverHome"){
			private static final long serialVersionUID = 1L;
			public void onClick() {
				AgregarEventoPage.this.setResponsePage(new HomePage());
			}});
			
			};
		
}
